<?php

namespace apiend\modules\setting\models;

use Yii;

/**
 * 店铺货运地址地址信息模型
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class StoreFreightAddressSearch extends \common\models\shop\ShopStoreFreightAddress {

    /**
     * @var status 状态
     */
    public $sort = [
        'defaultOrder' => [
            'created_at' => SORT_ASC,
        ]
    ];

    /**
     * Searching member apply
     * @param  array $params
     * @return \yii\data\ActiveDataProvider
     */
    public function buildQuery() {
        $query = static::find()->active();
        $query->andFilterWhere([
            'type' => $this->type
        ]);
        $query->debug();
        return $query;
    }

    /**
     * {@inheritdoc}
     */
    public function fieldConfigs() {
        return [
            'id',
            'name',
            'mobile',
            'province',
            'city',
            'district',
            'address_detail',
            'postal_code',
            'mark',
            [
                'class' => 'common\rest\grid\LabelColumn',
                'attribute' => 'is_default',
                'format' => 'boolean',
            ],
            [
                'class' => 'common\rest\grid\LabelColumn',
                'attribute' => 'status',
            ],
            [
                'attribute' => 'updated_at',
                'format' => 'datetime',
                'headerOptions' => ['class' => 'text-right'],
                'contentOptions' => ['class' => 'text-right'],
            ],
            [
                'class' => 'common\rest\grid\ActionColumn',
                'template' => '{update}',
                'headerOptions' => ['width' => '80'],
            ],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function configs() {
        return [
            'dialog' => [
                'visible' => false,
                'title' => '栏目内容设置'
            ],
            'config' => [
                'filterConfig' => [],
                'gridConfig' => $this->options(),
            ]
        ];
    }

}
